﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Bank_database_system.业务部
{
    public partial class 柜台业务a : UserControl
    {
        private string branch_id = "";
        private string staff_id = "";

        柜台业务b counter_business2 = new 柜台业务b();
        public 柜台业务a()
        {
            InitializeComponent();
            counter_business2.ButtonBack += BackToA;
        }
        private void BackToA(object sender, EventArgs e)
        {
            // 修改柜台业务a中的控件状态
            panel1.Visible = false;
            panel1.Controls.Clear();
        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (textBox2.TextLength == 20)
            {
                if (e.KeyChar != '\b')
                    e.Handled = true;
            }
            else
            {
                if ((e.KeyChar > '9' || e.KeyChar < '0') && e.KeyChar != '\b')
                    e.Handled = true;
            }
        }

        public void branch_and_staff_get(string branchID, string staffID)
        {
            branch_id = branchID;
            staff_id = staffID;
        }


        private void button9_Click(object sender, EventArgs e)
        {
            using (输入密码 passwords = new 输入密码(textBox2.Text))
            {
                // 显示 输入密码 作为模态窗体
                DialogResult p = passwords.ShowDialog();
                if (p == DialogResult.OK)
                {
                    // 获取 输入密码 中的结果
                    //切换到下一页面
                    panel1.Visible = true;
                    panel1.Controls.Clear();
                    counter_business2.CardID_Set(textBox2.Text);
                    counter_business2.branch_and_staff_get(branch_id, staff_id);
                    textBox2.Text = "";
                    panel1.Controls.Add(counter_business2);
                    panel1.BringToFront();//显示置顶
                }
                else if (p == DialogResult.No)
                {
                    MessageBox.Show("卡号或密码错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (p == DialogResult.Yes)
                {
                    MessageBox.Show("该账户已被冻结", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }



        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
